# -*- coding:utf-8 -*-
from infrastructure.utils.result import R
from interface.interface_base import app, request, jsonify
from service.stockBoardService import stockBoard, historyMaintain
from service.popularityGraphViewService import popularityGraphView


@app.route('/stockBoard/save', methods=['POST'])
def sbSave():
    dti = None
    if 'dti' in request.args:
        dti = request.args['dti']
    stockBoard(dti)
    return jsonify(R.success().__dict__)


@app.route('/stockBoard/popularityGraph', methods=['POST'])
def popularityGraph():
    popularityGraphView()
    return jsonify(R.success().__dict__)


@app.route('/stockBoard/historyMaintain', methods=['POST'])
def historyMaintainInterface():
    request_data = request.json
    return jsonify(historyMaintain(request_data['dtis']).__dict__)